package com.baidu.service.impl;

import com.baidu.mapper.UserMapper;
import com.baidu.pojo.User;
import com.baidu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper mapper;

    @Override
    public User selectByUsernameAndPassword(String username, String password) {
        Map map = new HashMap<>();
        map.put("username",username);
        map.put("password",password);
        List<User> ul =mapper.selectByUserNameAndPassword(map);
       if(ul!=null&&ul.size()>0){
            return ul.get(0);
       }
        return null;
    }


    @Override
    public List<User> selectAll() {
        return mapper.selectAll();
    }
}
